#pragma region Description
/*
     Copyright © 2011 Jesse 'LorgonJortle' Wilkerson
     See licensing in source (.cpp) file, or at:
     <http://www.gnu.org/licenses/> (GPL)

     File: SpriteBatch.h
     Author: Jesse 'LorgonJortle' Wilkerson
     Description:
          If you're doing any 2D rendering at all,
          you'll most likely be using the SpriteBatch.
          It allows you to render textures as sprites, and
          it also uses Fonts to draw strings.
*/
#pragma endregion

#ifndef SPRITEBATCH_H
#define SPRITEBATCH_H

/*****************************************
                              OpenGL
*****************************************/
     #ifdef __APPLE__
         #include <glew.h>
         #include <SDL/SDL.h>
         #include <SDL_ttf.h>
     #else
         #include <GL/glew.h>
         #include <SDL.h>
         #include <SDL_ttf.h>
     #endif
/****************************************/

/*****************************************
                         Standard C++
*****************************************/
     #include <iostream>
     #include <string>
     #include <vector>
/****************************************/

/*****************************************
                         LOGL::GLib
*****************************************/
     /*****************************************
                                   Common
     *****************************************/
          #include "Rect2.h"
          #include "Vector2.h"
          #include "Vector3.h"
          #include "Matrix.h"
          #include "ShaderManager.h"
          #include "Shaders.h"
          #include "Font.h"
     /*****************************************
                                   Content
     *****************************************/
          #include "Texture2.h"
/****************************************/


using namespace LOGL_GLib::Content;

namespace LOGL_GLib
{
     namespace Common
     {
          class SpriteBatch
          {
          public:
               /* Constructs a SpriteBatch object. */
               SpriteBatch();
               /* Destructs the SpriteBatch, releasing any indebted resources. */
               ~SpriteBatch();

               /* Initializes batch rendering. */
               static GLboolean Initialize(ShaderManager& _Shaders);
               /* Cleans up batch rendering. */
               static GLvoid Cleanup();
               /* Sets up orthogonal rendering. */
               GLboolean Begin(SDL_Surface* _Screen);
               /* Returns from orthogonal rendering. */
               GLvoid End();
               /*  Renders the specified string with the specified font in screen coordinates. */
               GLvoid DrawString2(const Font& _Font, const std::string& _Text, const Vector2& _Position, SDL_Color _Color);
               /* Renders the specified string with the specified font in game coordinates. */
               GLvoid DrawString3(const Font& _Font, const std::string& _Text, SDL_Color _Color);
               /* Renders the specified texture to the screen. */
               GLvoid DrawTexture(const Texture2& _Texture, const Vector2& _Position);

          private:
               /* Renders the specified string to an SDL surface. */
               SDL_Surface* RenderSurface(const Font& _Font, const std::string& _Text, SDL_Color _Color);

               /* The VBO ID of our quad. */
               static GLuint VBO;
               /* Whether or not the spritebatch is setup to render. */
               static GLboolean isSetup;
               /* The shader the spritebatch uses to render text. */
               static Shader shader;
               /* The ID of the projection matrix in the shader. */
               static GLuint shaderProjection;
               /* The ID of the modelview matrix in the shader. */
               static GLuint shaderModelView;
               /* The screen we're drawing to. */
               SDL_Surface* screen;
               /* A temporary storage for the font textures. */
               Texture2 texture;
               /* The modelview matrix for all fonts. */
               Matrix modelView;
               /* The projection matrix for all fonts. */
               Matrix projection;

          }; /* Class SpriteBatch. */
     } /* Namespace Common. */
} /* Namespace LOGL_GLib. */

#endif
